home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / tpv24.zip / V24.ASM < prev    next >
Assembly Source File  |  1990-11-23  |  3KB  |  87 lines

  1. ;//////////////////////////////////////////////////////////////////////////
  2. ;///                                                                    ///
  3. ;///           Turbo-Pascal V24-Interrupt-Support      V2.00            ///
  4. ;///                                                                    ///
  5. ;///                 (c) Christian Philipps, Moers                      ///
  6. ;///                    June 1988 / West-Germany                        ///
  7. ;///                                                                    ///
  8. ;///                Turbo Pascal 4.0 or above required                  ///
  9. ;///                                                                    ///
  10. ;//////////////////////////////////////////////////////////////////////////
  11.  
  12. ; This module is hereby donated to the public domain.
  13.  
  14. ;─────────────────────────────────────────────────────────────────────────
  15. ;                    Datensegment
  16. ;─────────────────────────────────────────────────────────────────────────
  17.  
  18. DATA     SEGMENT BYTE PUBLIC
  19.  
  20.          ; Turbo-Pascal Variable
  21.          EXTRN V24HP      : WORD
  22.          EXTRN V24TP      : WORD
  23.          EXTRN V24BuffEnd : WORD
  24.          EXTRN V24Buff    : BYTE
  25.          EXTRN ComBase    : WORD
  26.  
  27. DATA     ENDS
  28.  
  29. ;─────────────────────────────────────────────────────────────────────────
  30. ;                        Codesegment
  31. ;─────────────────────────────────────────────────────────────────────────
  32.  
  33. CODE     SEGMENT BYTE PUBLIC
  34.  
  35.          ASSUME CS:CODE, DS:DATA
  36.  
  37.          PUBLIC V24Int
  38.  
  39. ;─────────────────────────────────────────────────────────────────────────
  40.  
  41. ;CS-relative Daten
  42.  
  43. _Turbo_DS DW  DATA                              ; Turbo data segment
  44.                         ; (inserted by linkage editor)
  45.  
  46. ;─────────────────────────────────────────────────────────────────────────
  47. ;                    Codebereich
  48. ;─────────────────────────────────────────────────────────────────────────
  49. ;PROCEDURE V24Int; interrupt;
  50. ;  this routine is executed whenever a character arrives
  51.  
  52. V24Int   PROC  FAR                               ; Interrupt-Routine
  53.  
  54.  
  55. V24Int   ENDP
  56.  
  57.      push ds                                 ; save registers
  58.          push ax
  59.          push bx
  60.          push dx
  61.      mov  ds,CS:_Turbo_DS                    ; set Turbo DS
  62.  
  63.      mov  bx,V24TP                           ; ds:bx -> next free slot
  64.      mov  dx,ComBase                         ; dx = port base-address
  65.          in   al,dx                              ; RBR -> al
  66.      mov  byte ptr [bx],al                   ; move byte into buffer
  67.      inc  bx                                 ; pointer to next slot
  68.      cmp  bx,V24BuffEnd                      ; past the end of the buffer?
  69.      jle  L1                                 ; no
  70.      mov  bx,OFFSET V24Buff                  ; yes, so wrap around
  71.  
  72. L1:      cmp  bx,V24HP                           ; TP=HP --> overflow!
  73.      jz   L2                                 ; yes, ignore character
  74.      mov  V24TP,bx                           ; no, save new tail pointer
  75.  
  76. L2:      mov  al,20H                             ; EOI -> 8259
  77.          out  20H,al                             
  78.      pop  dx                                 ; restore registers
  79.          pop  bx
  80.          pop  ax
  81.          pop  ds
  82.          iret
  83.  
  84. CODE     ENDS
  85.  
  86. END
  87.